package qnb.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import qnb._common.easyui.EasyuiGridData;
import qnb._common.easyui.EasyuiPageVO;
import qnb._common.vo.MessageVOFactory;
import qnb.entity.Nafe;
import qnb.entity.PageResult;
import qnb.service.NafeService;
import weixinkeji.vip.jweb.power.ann.JWPIdentifiter;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
//import qnb.service.NafeService;


/**
 * @author huangxin
 * @date 2019/4/23-23:33
 */
@Controller
@RequestMapping(value = "/nafe", produces = "application/json; charset=utf-8")
public class NafeController {
    @Autowired
    private NafeService nafeService;

    @JWPIdentifiter("nafe:select")
    @RequestMapping("/forward/nafe")
    public ModelAndView forward(HttpSession session,ModelAndView modelAndView) {
        modelAndView.setViewName("nafe/nafe");

        return modelAndView;
    }

    @JWPIdentifiter("nafe:add")
    @RequestMapping("/add")
    @ResponseBody
    public String add(Nafe nafe) {
        return MessageVOFactory.getAddMessage(nafeService.add(nafe));
    }


    @JWPIdentifiter("nafe:delete")
    @PostMapping("/delete")
    @ResponseBody
    public String delete(Integer id) {
        return MessageVOFactory.getDellMessage(nafeService.delete(id));
    }

    @JWPIdentifiter("nafe:delete")
    @PostMapping("/deleteByIds")
    @ResponseBody
    public String deleteByIds(@RequestParam("ids") List<Integer> ids) {
        return MessageVOFactory.getDellMessage(nafeService.deleteByIds(ids));
    }
    @JWPIdentifiter("nafe:update")
    @RequestMapping("/update")
    @ResponseBody
    public String update(Nafe nafe) {

        return MessageVOFactory.getUpdateMessage( nafeService.update(nafe));
    }
    @JWPIdentifiter("nafe:select")
    @RequestMapping("/listByPage")
    @ResponseBody
    public EasyuiGridData listByPage(Nafe nafe, EasyuiPageVO vo) {

        return nafeService.listByPage(nafe, vo);
    }
    @JWPIdentifiter("nafe:select")
    @RequestMapping("/get")
    @ResponseBody
    public Nafe get(Integer id) {
        return nafeService.get(id);
    }


}
